<?php


namespace App\Http\Controllers\Common;

use App\Http\Controllers\BaseController;
use App\Exceptions\BasicException;  //引入框架异常处理类
use App\Repositories\LogRepository;
use App\Services\Tools\RedisService;
use Illuminate\Http\Request;        //引用http请求类
use App\Response\Response;
class MessageController extends BaseController
{
    public function getWhitelistAD(Request $request)
    {
        $user_id = $request->input('user_id');
        // 获取当前的 所有白名单
        $data = RedisService::whitelistList($user_id);
        foreach ($data as $key => $val){
            app('rongcloud')->whitelist($key, [$user_id]);
            RedisService::delWhitelist($key, $user_id);
        }
        return Response::sendData('ok');
    }

//    public function test(Request $request){
//        $user_id = $request->input('user_id');
//        $param = [
//          'user_id' =>   $user_id
//        ];
//        $url = env('APP_URL').'/whitelist/ad';
//        $headers = [
//            'sign' => md5($user_id.'789654321qaz')
//        ];
//        $ch = curl_init();
//        curl_setopt($ch, CURLOPT_TIMEOUT, 6);
//        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//        curl_setopt($ch, CURLOPT_POST, true);
//        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
//        curl_setopt($ch, CURLOPT_URL, $url);
//        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 2);
//        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//        $ret = curl_exec($ch);
//        curl_close($ch);
//        $result = json_decode($ret, true);
//        return Response::sendData($result);
//    }
}
